package com.gsn.engine.gdx;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor;

public class GsnRepeatingActor extends Actor {
	SpriteBatch spriteBatch;
	Texture spriteTexture;
	Sprite sprite;

	public GsnRepeatingActor(Texture texture, int width, int height) {
		// TODO Auto-generated constructor stub
		spriteBatch = new SpriteBatch();
		spriteTexture = new Texture(Gdx.files.internal("tmp/avatar.png"));

		spriteTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);

		sprite = new Sprite(spriteTexture, 0, 0, width, height);
		this.width = width;
		this.height = height;
	}
	
	public void setPosition(float x, float y){
		this.x = x;
		this.y = y;
		sprite.setPosition(x, y);
	}

	@Override
	public void draw(SpriteBatch batch, float parentAlpha) {
		// TODO Auto-generated method stub
		sprite.draw(batch);
	}

	@Override
	public Actor hit(float x, float y) {
		// TODO Auto-generated method stub
		if (x >= 0 && y >=0 && x <= width && y <= height)
			return this;
		else
			return null;
	}
}
